﻿using System;
using System.Collections.Generic;
using System.IO;

namespace ScriptGenerator {
  class Program {
    static void Main(string[] args) {

      DirectoryInfo dinfo = new DirectoryInfo("c:/nsworkspace");
      FileInfo[] finfos = dinfo.GetFiles("adi2d_*");
      List<String> filelist = new List<string>();

      for (int i = 0; i < finfos.Length; i++) {
        filelist.Add(finfos[i].FullName);
      }
      filelist.Sort();

      StreamWriter writer = File.CreateText("c:/nsworkspace/script.txt");

      writer.WriteLine("set pm3d");
      writer.WriteLine("set view 60.0,320.0");
      writer.WriteLine("set cbrange [0.0:1.0]");
      writer.WriteLine("set terminal gif");
      writer.WriteLine("set size 1.0,1.0");

      for (int i = 0; i < finfos.Length; i++) {
        String filename = finfos[i].FullName;
        String giffile = filename.Replace(".txt", ".gif");
        writer.WriteLine("set output '" + giffile + "'");
        writer.WriteLine("splot [0:1][0:1][0:1] '" + filename + "' with pm3d");
      }
      writer.WriteLine("unset output");
      writer.Close();
    }
  }
}
